package com.miyu.client1.controller.user;

import cn.dev33.satoken.session.SaSession;
import cn.dev33.satoken.stp.StpUtil;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class userLogin {


    @RequestMapping("/userLogin")
    public JSONObject userLogin(@RequestBody String str){
        JSONObject  rs = new JSONObject();

        StpUtil.setLoginId(10001);
        System.out.println("接收参数"+str);

        // 然后在任意需要校验登录处调用以下API  --- 如果当前会话未登录，这句代码会抛出 `NotLoginException`异常
        StpUtil.checkLogin();
        SaSession sa=StpUtil.getTokenSession();
        Object loginId = StpUtil.getLoginId();
        System.out.println(loginId);
        System.out.println(sa);

        rs.put("msg",str);
        return  rs;
    }

    @RequestMapping("/queryToken")
    public String queryAll(){
        Object loginIdByToken =  StpUtil.getLoginId();
        String loginDevice = StpUtil.getLoginDevice();
        String le = StpUtil.getLoginId("10001");
        System.out.println("aaaaaaaaa>>>>>>>>>>>>>>"+loginIdByToken);
        System.out.println("aaaaaaaaa>>>>>>>>>>>>>>"+loginDevice);
        System.out.println("aaaaaaaaa>>>>>>>>>>>>>>"+le);

        return  "test";
    }

}
